package com.da.javatest.leetCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chenlida
 * @date 2019/2/27 15:58
 * @description
 */
public class Code234 {
    private List<Integer> list = new ArrayList<>();

    public boolean isPalindrome(ListNode head) {
        setList(head);
        for (int i = 0; i < list.size() / 2; i++) {
            if (!list.get(i).equals(list.get(list.size() - i - 1))) {
                return false;
            }
        }
        return true;
    }

    private void setList(ListNode node) {
        if (node != null) {
            list.add(node.val);
            setList(node.next);
        }
    }
}
